function Foo() {
  this.a = 1;
  this.b = 2;
}
const o = new Foo();
console.log(JSON.stringify(o)); // {"a":1,"b":2}
